package com.dubbo.provider.serviceImpl;


import com.dubbo.api.entity.UserDO;
import com.dubbo.api.service.UserService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @SuppressWarnings("serial")
    private List<UserDO> users = new ArrayList<UserDO>(){{
        add(new UserDO(1L, "熊大", "123"));
        add(new UserDO(2L, "熊二", "234"));
        add(new UserDO(3L, "熊三", "456"));
    }};

    /**
     * <p>覆盖方法：findById</p>
     * <p>描述：通过id查询用户</p>
     * @param id
     * @return
     * @see
     */
    @Override
    public UserDO findById(Long id) {
        return users.stream().filter(user -> user.getId() == id).findFirst().get();
    }

    /**
     * <p>覆盖方法：listUser</p>
     * <p>描述：查询用户列表</p>
     * @return
     * @see
     */
    @Override
    public List<UserDO> listUser() {
        return users;
    }
}
